﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RockScissorPaper
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        //总分
        private int sum = 0;

        private void btnRock_Click(object sender, EventArgs e)
        {
            var fistStr = "石头";
            Play(fistStr);
        }

        private void btnScissor_Click(object sender, EventArgs e)
        {
            var fistStr = "剪刀";
            Play(fistStr);
        }

        private void btnPaper_Click(object sender, EventArgs e)
        {
            var fistStr = "布";
            Play(fistStr);
        }
        //游戏调用
        private void Play(string fistStr)
        {
            //玩家出石头
            lblPlayer.Text = fistStr;
            var play = new Player();
            var enumPlayer = play.ShowFist(fistStr);

            //电脑出拳
            var com = new Computer();
            var enumCom = com.ShowFist();
            lblComputer.Text = com.Fist.ToString();

            //裁判出场
            var enumResult = Judge.GetResult((int)enumPlayer, (int)enumCom);
            lblResult.Text = enumResult.ToString();
            //计数器
            if (lblResult.Text == "玩家赢" && !(lblResult.Text == "平手"))
            {
                lblPlayerScore.Text = sum.ToString();
                sum++;
            }
            else
            {
                lblComputerScore.Text = sum.ToString();
                sum++;
            }
        }
    }
}
